/*
* @Author: Choisaaaa
* @Date: 2018/5/5  1:34
* 订单模块的业务处理
*/

import Mutil from "util/mm.jsx";
const _mm = new Mutil();

class Order{
    //1.获取订单列表
    getOrderList(listParam){
        let url = "",
            data = {};
        if(listParam.listType === "list"){//按列表查询
            url             = '/manage/order/list.do';
            data.pageNum    = listParam.pageNum;
        }else if(listParam.listType === "search"){ //按搜索查询
            url = '/manage/order/search.do';
            data.pageNum    = listParam.pageNum;
            data.orderNo    = listParam.orderNo;
        }
        return _mm.request({
            type: 'post',
            url: url,
            data: data
        });
    }
    //2.获取订单详情
    getOrderDetail(orderNumber){
        return _mm.request({
            type    : 'post',
            url     : '/manage/order/detail.do',
            data    : {
                orderNo : orderNumber
            }
        });
    }
    //3.订单发货
    sendGoods(orderNumber){
        return _mm.request({
            type    : 'post',
            url     : '/manage/order/send_goods.do',
            data    : {
                orderNo : orderNumber
            }
        });
    }
    //4.查找订单时验证字段
    checkOrderNumber(orderNumber){
        let result = {
            status: true,
            msg: '验证通过'
        };
        if(!(/^[-0-9#()]+$/.test(orderNumber))){
           return{
               status: false,
               msg: '输入订单号格式不正确'
           }
        }
        return  result;
    }
}
export default Order;